# app/utils/time.py
## 时间转换工具 ##。。
from datetime import datetime
import pytz
from app.core.config import settings

def convert_to_local_time(utc_time: datetime) -> datetime:
    """将UTC时间转换为本地时间"""
    local_tz = pytz.timezone(settings.TORTOISE_ORM["timezone"])
    local_time = utc_time.astimezone(local_tz)
    return local_time.replace(tzinfo=None)  # 移除时区信息以匹配数据库

def convert_to_utc_time(local_time: datetime) -> datetime:
    """将本地时间转换为UTC时间"""
    local_tz = pytz.timezone(settings.TORTOISE_ORM["timezone"])
    local_time = local_tz.localize(local_time)
    return local_time.astimezone(pytz.UTC)